# -*- coding: utf-8 -*-
from odoo import api, fields, models
from odoo.exceptions import ValidationError


class GymPurchaseOrder(models.Model):
    _inherit = 'purchase.order.line'

    # 塞選出該供應商所提供的商品
    @api.onchange('product_id')
    def set_domain_product(self):
        supply_ids = self.order_id.partner_id
        res = self.env['product.template']
        for line in supply_ids.supply_product:
            res += line.product_tmpl_id

        return {
            'domain': {
                'product_id': [('product_tmpl_id', 'in', res.ids)],
            }}





